package com.example.service;

import com.example.entity.Params;
import com.example.entity.Type;
import com.example.mapper.TypeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeService {
    @Resource
    private TypeMapper typeMapper;

    public List<Type> findAll() {
        return typeMapper.selectA();
    }


    public PageInfo<Type> findBySearch(Params params) {
        PageHelper.startPage(params.getPageNum(), params.getPageSize());


        List<Type> list = typeMapper.findBySearch(params);
        return PageInfo.of(list);
    }

    public void add(Type type) {
        typeMapper.add(type);
    }

    public void update(Type type) {
        typeMapper.update(type);
    }


    public void delete(Integer id) {

        typeMapper.deleteById(id);
    }


}
